home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-01-29 | 40.0 KB | 1,316 lines |
- Newsgroups: comp.sources.misc
- From: dvadura@plg.waterloo.edu (Dennis Vadura)
- Subject: v27i105: dmake - dmake Version 3.8, Part04/41
- Message-ID: <1992Jan28.031206.6937@sparky.imd.sterling.com>
- X-Md4-Signature: 368bb50c9e7418fad1fe40f43f184c22
- Date: Tue, 28 Jan 1992 03:12:06 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: dvadura@plg.waterloo.edu (Dennis Vadura)
- Posting-number: Volume 27, Issue 105
- Archive-name: dmake/part04
- Environment: Atari-ST, Coherent, Mac, MSDOS, OS/2, UNIX
- Supersedes: dmake: Volume 19, Issue 22-58
-
- ---- Cut Here and feed the following to sh ----
- # this is dmake.shar.04 (part 4 of a multipart archive)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file dmake/dbug/dbug/dbug.uue continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 4; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test -f _shar_wnt_.tmp; then
- sed 's/^X//' << 'SHAR_EOF' >> 'dmake/dbug/dbug/dbug.uue' &&
- M2B'8ZSA!Z_024_ZP2,),<,)]TQ+7HV\P>:&O7K\S21"#S_9!9W],773'GA-4
- MCM1LX )CH ,&D0,Z<-Q5ON<ZX/0.H@-.'RF22N5(/9SX1^5(S08N, 8Z8! Y
- MH /'7>5[K@-.[R ZX/21 JA4CM3#B7]4CM1LX )CH ,&D0,Z<-Q5ON<ZX/0.
- MH@-.'RD=1>5(/9SX1^5(S08N, 8ZH$\SH /'7>5[K@-0;'HZ ,6FITJB">.U
- MS@8N, 8ZH$\SH /'7>5[K@-0;'HZ ,6FITH."^.US@8N, 8ZH$\SH /'7>5[
- MK@-0;'HZ ,6FITHZY5( 2.<34<S^];!4CM0=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!<7^"5^6N
- M$;U#\KHD;9/P:Q#K,6GY!B*?CQ?P5(@A-T9\0^DZK_E%&D: Y&C@F)V\D_T4
- M$^7P#@)/T$+TX=9E<)SHH1Y]$4GH4>\(L1YPXEUEFJV6W_E[HJ2JI-.>008?
- M,R/SDB&E0_9/CSYEEQ<M('<"DHN#"T? 3Q%]'AXZ(OK,U!CBB%K*\<%&=1V4
- MKO/Q-"($;%[PA?Z)ONB&P@8(P 8(P 8(H!P(P 8(P 8(H!@(\ 8(\ 8(\,$(
- M, 8(, 8(D'#/=--R1OK(6(\^S&R[81VO!WD:\])@!ERR1$6_^]5XH1>7)B!U
- 6JTKA=5]I *"4_\%4D\0&T1CB.!Q$ 1VO
- X
- end
- SHAR_EOF
- chmod 0640 dmake/dbug/dbug/dbug.uue ||
- echo 'restore of dmake/dbug/dbug/dbug.uue failed'
- Wc_c="`wc -c < 'dmake/dbug/dbug/dbug.uue'`"
- test 22625 -eq "$Wc_c" ||
- echo 'dmake/dbug/dbug/dbug.uue: original size 22625, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= dmake/dbug/getwd.c ==============
- if test -f 'dmake/dbug/getwd.c' -a X"$1" != X"-c"; then
- echo 'x - skipping dmake/dbug/getwd.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/getwd.c' &&
- char *
- getwd(pathname)
- char *pathname;
- {
- X return("delete this code if your getwd.c works correctly");
- }
- SHAR_EOF
- chmod 0640 dmake/dbug/getwd.c ||
- echo 'restore of dmake/dbug/getwd.c failed'
- Wc_c="`wc -c < 'dmake/dbug/getwd.c'`"
- test 106 -eq "$Wc_c" ||
- echo 'dmake/dbug/getwd.c: original size 106, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= dmake/dbug/malloc/Makefile ==============
- if test ! -d 'dmake/dbug/malloc'; then
- mkdir 'dmake/dbug/malloc'
- fi
- if test -f 'dmake/dbug/malloc/Makefile' -a X"$1" != X"-c"; then
- echo 'x - skipping dmake/dbug/malloc/Makefile (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/Makefile' &&
- #
- # (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
- # You may copy, distribute, and use this software as long as this
- # copyright statement is not removed.
- #
- #
- # This is the Makefile for the malloc debugging library
- #
- # $Id: Makefile,v 1.5 90/08/29 22:34:27 cpcahil Exp $
- #
- CC=cc
- # for System V systems use this CFLAGS
- #CFLAGS=-g -DSYS5
- # else for BSD use:
- #CFLAGS=-g
- LINT=lint
- SHARCMD=shar -o mallocshar -l50 -x -a -n Malloclib
- SHELL=/bin/sh
- X
- LIB=libmalloc.a
- X
- SRCS= malloc.c \
- X free.c \
- X realloc.c \
- X calloc.c \
- X string.c \
- X mlc_chk.c \
- X mlc_chn.c \
- X memory.c \
- X tostring.c \
- X m_perror.c \
- X m_init.c \
- X mallopt.c \
- X dump.c
- X
- OBJS= malloc.o \
- X free.o \
- X realloc.o \
- X calloc.o \
- X string.o \
- X mlc_chk.o \
- X mlc_chn.o \
- X memory.o \
- X tostring.o \
- X m_perror.o \
- X m_init.o \
- X mallopt.o \
- X dump.o
- X
- TESTS=testmlc testmem
- X
- all: $(LIB) $(TESTS)
- X
- clean:
- X rm -f $(TESTS) pgm $(LIB) *.o *.ln
- X
- sharfile:
- X $(SHARCMD) Makefile README patchlevel *.[ch3]
- X
- $(LIB): $(OBJS)
- X ar ru $(LIB) $(OBJS)
- X -if test -s /bin/ranlib; then /bin/ranlib $(LIB); else exit 0; fi
- X -if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(LIB); else exit 0; fi
- X
- testmlc: $(LIB) testmlc.o
- X $(CC) -o $@ testmlc.o $(LIB)
- X
- testmem: $(LIB) testmem.o
- X $(CC) -o $@ testmem.o $(LIB)
- X
- lint:
- X $(LINT) $(CFLAGS) $(SRCS) testmlc.c testmem.c
- X
- X
- $(OBJS): malloc.h
- X
- tostring.o malloc.o dump.o: tostring.h
- SHAR_EOF
- chmod 0640 dmake/dbug/malloc/Makefile ||
- echo 'restore of dmake/dbug/malloc/Makefile failed'
- Wc_c="`wc -c < 'dmake/dbug/malloc/Makefile'`"
- test 1365 -eq "$Wc_c" ||
- echo 'dmake/dbug/malloc/Makefile: original size 1365, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= dmake/dbug/malloc/_changes ==============
- if test -f 'dmake/dbug/malloc/_changes' -a X"$1" != X"-c"; then
- echo 'x - skipping dmake/dbug/malloc/_changes (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/_changes' &&
- I made the following changes to the malloc package as found in
- comp.sources.unix:
- X
- X 1. created this file _changes.
- X 2. moved README to _readme (facilitates transfer to DOS and back to
- X unix)
- X 3. renamed testmalloc.c, malloc_chk.c, and malloc_chn.c to testmlc.c,
- X mlc_chk.c, and mlc_chn.c respectively. Again DOS has trouble with
- X long basenames in filenames.
- SHAR_EOF
- chmod 0640 dmake/dbug/malloc/_changes ||
- echo 'restore of dmake/dbug/malloc/_changes failed'
- Wc_c="`wc -c < 'dmake/dbug/malloc/_changes'`"
- test 369 -eq "$Wc_c" ||
- echo 'dmake/dbug/malloc/_changes: original size 369, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= dmake/dbug/malloc/_readme ==============
- if test -f 'dmake/dbug/malloc/_readme' -a X"$1" != X"-c"; then
- echo 'x - skipping dmake/dbug/malloc/_readme (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/_readme' &&
- # (c) Copyright 1990 Conor P. Cahill. (uunet!virtech!cpcahil)
- # You may copy, distribute, and use this software as long as this
- # copyright statement is not removed.
- X
- This package is a collection of routines which are a drop-in replacement
- for the malloc(3), memory(3), string(3), and bstring(3) library functions.
- X
- The purpose of these programs is to aid the development and/or debugging
- of programs using these functions by providing a high level of consistancy
- checking whenever a malloc pointer is used. Due to this increased
- level of consistancy checking, these functions have a considerably larger
- overhead than the standard functions, but the extra checking should be
- well worth it in a development environment.
- X
- To use these functions all you need to do is compile the library and
- include it on your loader command line. You do not need to recompile
- your code, only a relink is necessary.
- X
- Features of this library:
- X
- X 1. The malloced area returned from each call to malloc is filled with
- X non-null bytes. This should catch any use of uninitialized malloc
- X area. The fill pattern for malloced area is 0x01.
- X
- X 2. When free is called numerous validity checks are made on the
- X pointer it is passed. In addition, the data in the malloc block
- X beyound the size requested on the initial malloc is checked to
- X verify that it is still filled with the original fill characters.
- X
- X This is usefull for catching things like:
- X
- X ptr = malloc(5);
- X ptr[5] = '\0';
- X
- X /*
- X * You should not that this will be caught when it is
- X * freed not when it is done
- X */
- X
- X And finally, the freed block is filled with a different fill pattern
- X so that you can easily determine if you are still using free'd space.
- X The fill pattern for free'd areas is 0x02.
- X
- X This is usefull for catching things like:
- X
- X ptr = malloc(20);
- X
- X bptr = ptr+10;
- X
- X /* do something usefule with bptr */
- X
- X free(ptr);
- X
- X /*
- X * now try to do something useful with bptr, it should
- X * be trashed enough that it would cause real problems
- X * and when you went to debug the problem it would be
- X * filled with 0x02's and you would then know to look
- X * for something free'ing what bptr points to.
- X */
- X
- X
- X 3. Whenever a bstring(3)/string(3)/memory(3) function is called, it's
- X parameters are checked as follows:
- X
- X If they point somewhere in the malloc arena
- X If the operation goes beyond requested malloc space
- X call malloc_warning()
- X
- X This is usefull for catching things like:
- X
- X ptr = malloc(5);
- X strcpy(ptr,"abcde");
- X
- X
- X 4. Malloc_warning() and malloc_fatal() are used when an error condition
- X is detected. If the error is severe, malloc_fatal is called.
- X Malloc_warning is used otherwise. The decision about what is fatal
- X and what is a warning was made somewhat arbitrarily.
- X
- X Warning messages include:
- X
- X Calling free with a bad pointer
- X Calling a bstring/string/memory (3) function which will go beyond
- X the end of a malloc block (Note that the library function is
- X not modified to refuse the operation. If malloc warnings are
- X in the default IGNORE case, the operation will continue and
- X at some point cause a real problem).
- X
- X Fatal errors are:
- X
- X Detectable corruption to the malloc chain.
- X
- X
- X 5. The operations to perform when an error is detected are specified at
- X run time by the use of environment variables.
- X
- X MALLOC_WARN - specifies the warning error message handling
- X MALLOC_FATAL - specifies the fatal error handling
- X
- X
- X When one of these error conditions occur you will get an error
- X message and the handler will execute based upon what setting
- X is in the environment variables. Currently understood settings
- X are as follows:
- X
- X 0 - continue operations
- X 1 - drop core and exit
- X 2 - just exit
- X 3 - drop core, but continue executing. Core files will
- X be placed into core.[PID].[counter] i.e: core.00123.001
- X 128 - dump malloc chain and continue
- X 129 - dump malloc chain, dump core, and exit
- X 130 - dump malloc chain, exit
- X 131 - dump malloc chain, dump core, continue processing
- X
- X
- X There is an additional environment variable MALLOC_ERRFILE which
- X is used to indicate the name of the file for error message output.
- X
- X For example, to set up the session to generate a core file for
- X every malloc warning, to drop core and exit on a malloc fatal, and
- X to log all messages to the file "malloc_log" do the following:
- X
- X MALLOC_WARN=131
- X MALLOC_FATAL=1
- X MALLOC_ERRFILE=malloc_log
- X
- X export MALLOC_WARN MALLOC_FATAL MALLOC_ERRFILE
- X
- X 6. The function malloc_dump() is available to dump the malloc chain whenever
- X you might want. It's only argument is a file descriptor to use to write
- X the data. Review the code if you need to know what data is printed.
- SHAR_EOF
- chmod 0640 dmake/dbug/malloc/_readme ||
- echo 'restore of dmake/dbug/malloc/_readme failed'
- Wc_c="`wc -c < 'dmake/dbug/malloc/_readme'`"
- test 4758 -eq "$Wc_c" ||
- echo 'dmake/dbug/malloc/_readme: original size 4758, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= dmake/dbug/malloc/calloc.c ==============
- if test -f 'dmake/dbug/malloc/calloc.c' -a X"$1" != X"-c"; then
- echo 'x - skipping dmake/dbug/malloc/calloc.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/calloc.c' &&
- /*
- X * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
- X * You may copy, distribute, and use this software as long as this
- X * copyright statement is not removed.
- X */
- #include <stdio.h>
- X
- /*
- X * Function: calloc()
- X *
- X * Purpose: to allocate and nullify a data area
- X *
- X * Arguments: nelem - number of elements
- X * elsize - size of each element
- X *
- X * Returns: NULL - if malloc fails
- X * or pointer to allocated space
- X *
- X * Narrative: determine size of area to malloc
- X * malloc area.
- X * if malloc succeeds
- X * fill area with nulls
- X * return ptr to malloc'd region
- X */
- #ifndef lint
- static char rcs_header[] = "$Id: calloc.c,v 1.1 1992/01/24 03:28:58 dvadura Exp $";
- #endif
- X
- char *
- calloc(nelem,elsize)
- X unsigned int nelem;
- X unsigned int elsize;
- {
- X char * malloc();
- X char * memset();
- X char * ptr;
- X unsigned int size;
- X
- X size = elsize * nelem;
- X
- X if( (ptr = malloc(size)) != NULL)
- X {
- X (void) memset(ptr,'\0',(int)size);
- X }
- X
- X return(ptr);
- }
- X
- X
- /*
- X * $Log: calloc.c,v $
- X * Revision 1.1 1992/01/24 03:28:58 dvadura
- X * dmake Version 3.8, Initial revision
- X *
- X * Revision 1.6 90/05/11 00:13:07 cpcahil
- X * added copyright statment
- X *
- X * Revision 1.5 90/02/24 20:41:57 cpcahil
- X * lint changes.
- X *
- X * Revision 1.4 90/02/24 17:25:47 cpcahil
- X * changed $header to $id so full path isn't included.
- X *
- X * Revision 1.3 90/02/24 13:32:24 cpcahil
- X * added function header. moved log to end of file.
- X *
- X * Revision 1.2 90/02/22 23:08:26 cpcahil
- X * fixed rcs_header line
- X *
- X * Revision 1.1 90/02/22 23:07:38 cpcahil
- X * Initial revision
- X *
- X */
- SHAR_EOF
- chmod 0640 dmake/dbug/malloc/calloc.c ||
- echo 'restore of dmake/dbug/malloc/calloc.c failed'
- Wc_c="`wc -c < 'dmake/dbug/malloc/calloc.c'`"
- test 1572 -eq "$Wc_c" ||
- echo 'dmake/dbug/malloc/calloc.c: original size 1572, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= dmake/dbug/malloc/debug.h ==============
- if test -f 'dmake/dbug/malloc/debug.h' -a X"$1" != X"-c"; then
- echo 'x - skipping dmake/dbug/malloc/debug.h (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/debug.h' &&
- /*
- X * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
- X * You may copy, distribute, and use this software as long as this
- X * copyright statement is not removed.
- X */
- /************************************************************************/
- /* */
- /* this include sets up some macro functions which can be used while */
- /* debugging the program, and then left in the code, but turned of by */
- /* just not defining "DEBUG". This way your production version of */
- /* the program will not be filled with bunches of debugging junk */
- /* */
- /************************************************************************/
- /*
- X * $Id: debug.h,v 1.1 1992/01/24 03:28:59 dvadura Exp $
- X */
- X
- #ifdef DEBUG
- X
- #if DEBUG == 1 /* if default level */
- #undef DEBUG
- #define DEBUG 100 /* use level 100 */
- #endif
- X
- #include <stdio.h>
- X
- #define DEBUG0(val,str)\
- X {\
- X if( DEBUG > val ) \
- X fprintf(stderr,"%s(%d): %s\n",\
- X __FILE__,__LINE__,str);\
- X }
- #define DEBUG1(val,str,a1)\
- X {\
- X char _debugbuf[100];\
- X if( DEBUG > val )\
- X {\
- X sprintf(_debugbuf,str,a1);\
- X fprintf(stderr,"%s(%d): %s\n",\
- X __FILE__,__LINE__,_debugbuf);\
- X }\
- X }
- X
- #define DEBUG2(val,str,a1,a2)\
- X {\
- X char _debugbuf[100];\
- X if( DEBUG > val )\
- X {\
- X sprintf(_debugbuf,str,a1,a2);\
- X fprintf(stderr,"%s(%d): %s\n",\
- X __FILE__,__LINE__,_debugbuf);\
- X }\
- X }
- X
- #define DEBUG3(val,str,a1,a2,a3)\
- X {\
- X char _debugbuf[100];\
- X if( DEBUG > val )\
- X {\
- X sprintf(_debugbuf,str,a1,a2,a3);\
- X fprintf(stderr,"%s(%d): %s\n",\
- X __FILE__,__LINE__,_debugbuf);\
- X }\
- X }
- X
- #define DEBUG4(val,str,a1,a2,a3,a4)\
- X {\
- X char _debugbuf[100];\
- X if( DEBUG > val )\
- X {\
- X sprintf(_debugbuf,str,a1,a2,a3,a4);\
- X fprintf(stderr,"%s(%d): %s\n",\
- X __FILE__,__LINE__,_debugbuf);\
- X }\
- X }
- X
- #define DEBUG5(val,str,a1,a2,a3,a4,a5)\
- X {\
- X char _debugbuf[100];\
- X if( DEBUG > val )\
- X {\
- X sprintf(_debugbuf,str,a1,a2,a3,a4,a5);\
- X fprintf(stderr,"%s(%d): %s\n",\
- X __FILE__,__LINE__,_debugbuf);\
- X }\
- X }
- X
- #else
- X
- #define DEBUG0(val,s)
- #define DEBUG1(val,s,a1)
- #define DEBUG2(val,s,a1,a2)
- #define DEBUG3(val,s,a1,a2,a3)
- #define DEBUG4(val,s,a1,a2,a3,a4)
- #define DEBUG5(val,s,a1,a2,a3,a4,a5)
- X
- #endif /* DEBUG */
- X
- X
- /*
- X * $Log: debug.h,v $
- X * Revision 1.1 1992/01/24 03:28:59 dvadura
- X * dmake Version 3.8, Initial revision
- X *
- X * Revision 1.2 90/05/11 00:13:08 cpcahil
- X * added copyright statment
- X *
- X * Revision 1.1 90/02/23 07:09:01 cpcahil
- X * Initial revision
- X *
- X */
- SHAR_EOF
- chmod 0640 dmake/dbug/malloc/debug.h ||
- echo 'restore of dmake/dbug/malloc/debug.h failed'
- Wc_c="`wc -c < 'dmake/dbug/malloc/debug.h'`"
- test 2719 -eq "$Wc_c" ||
- echo 'dmake/dbug/malloc/debug.h: original size 2719, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= dmake/dbug/malloc/dump.c ==============
- if test -f 'dmake/dbug/malloc/dump.c' -a X"$1" != X"-c"; then
- echo 'x - skipping dmake/dbug/malloc/dump.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/dump.c' &&
- /*
- X * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
- X * You may copy, distribute, and use this software as long as this
- X * copyright statement is not removed.
- X */
- #include <stdio.h>
- #include "malloc.h"
- #include "tostring.h"
- X
- /*
- X * Function: malloc_dump()
- X *
- X * Purpose: to dump a printed copy of the malloc chain and
- X * associated data elements
- X *
- X * Arguments: fd - file descriptor to write data to
- X *
- X * Returns: nothing of any use
- X *
- X * Narrative: Just print out all the junk
- X *
- X * Notes: This function is implemented using low level calls because
- X * of the likelyhood that the malloc tree is damaged when it
- X * is called. (Lots of things in the c library use malloc and
- X * we don't want to get into a catch-22).
- X *
- X */
- X
- #ifndef lint
- static
- char rcs_hdr[] = "$Id: dump.c,v 1.1 1992/01/24 03:29:01 dvadura Exp $";
- #endif
- X
- X
- #define ERRSTR "I/O Error on malloc dump file descriptor\n"
- X
- #define WRITEOUT(fd,str,len) if( write(fd,str,(unsigned)len) != len ) \
- X { \
- X (void) write(2,ERRSTR,\
- X (unsigned)strlen(ERRSTR));\
- X exit(120); \
- X }
- X
- void
- malloc_dump(fd)
- X int fd;
- {
- X char buffer[512];
- X void exit();
- X int i;
- X extern char * malloc_data_end;
- X extern char * malloc_data_start;
- X extern struct mlist * malloc_end;
- X extern struct mlist malloc_start;
- X struct mlist * ptr;
- X
- X WRITEOUT(fd,"MALLOC CHAIN:\n",14);
- X WRITEOUT(fd,"-------------------- START ----------------\n",44);
- X
- X for(i=0; i < 80; i++)
- X {
- X buffer[i] = ' ';
- X }
- X
- X for(ptr = &malloc_start; ptr; ptr = ptr->next)
- X {
- X (void) tostring(buffer, (int)ptr, 8, B_HEX, '0');
- X (void) tostring(buffer+9, (int)ptr->next, 8, B_HEX, '0');
- X (void) tostring(buffer+18, (int)ptr->prev, 8, B_HEX, '0');
- X (void) tostring(buffer+27, (int)ptr->flag, 10, B_HEX, '0');
- X (void) tostring(buffer+38, (int)ptr->s.size, 8, B_DEC, ' ');
- X (void) tostring(buffer+47, (int)ptr->s.size, 8, B_HEX, '0');
- X (void) tostring(buffer+57, (int)ptr->data, 8, B_HEX, '0');
- X buffer[46] = '(';
- X buffer[55] = ')';
- X buffer[65] = '\n';
- X WRITEOUT(fd,buffer,66);
- X }
- X WRITEOUT(fd,"-------------------- DONE -----------------\n",44);
- X
- X WRITEOUT(fd,"Malloc start: ",19);
- X (void) tostring(buffer, (int) &malloc_start, 8, B_HEX, '0');
- X buffer[8] = '\n';
- X WRITEOUT(fd,buffer,9);
- X
- X WRITEOUT(fd,"Malloc end: ", 19);
- X (void) tostring(buffer, (int) malloc_end, 8, B_HEX, '0');
- X buffer[8] = '\n';
- X WRITEOUT(fd,buffer,9);
- X
- X WRITEOUT(fd,"Malloc data start: ", 19);
- X (void) tostring(buffer, (int) malloc_data_start, 8, B_HEX, '0');
- X buffer[8] = '\n';
- X WRITEOUT(fd,buffer,9);
- X
- X WRITEOUT(fd,"Malloc data end: ", 19);
- X (void) tostring(buffer, (int) malloc_data_end, 8, B_HEX, '0');
- X buffer[8] = '\n';
- X WRITEOUT(fd,buffer,9);
- X
- } /* malloc_dump(... */
- X
- X
- /*
- X * $Log: dump.c,v $
- X * Revision 1.1 1992/01/24 03:29:01 dvadura
- X * dmake Version 3.8, Initial revision
- X *
- X * Revision 1.5 90/08/29 21:22:37 cpcahil
- X * miscellaneous lint fixes
- X *
- X * Revision 1.4 90/05/11 00:13:08 cpcahil
- X * added copyright statment
- X *
- X * Revision 1.3 90/02/24 21:50:07 cpcahil
- X * lots of lint fixes
- X *
- X * Revision 1.2 90/02/24 17:27:48 cpcahil
- X * changed $header to $Id to remove full path from rcs id string
- X *
- X * Revision 1.1 90/02/22 23:17:43 cpcahil
- X * Initial revision
- X *
- X */
- SHAR_EOF
- chmod 0640 dmake/dbug/malloc/dump.c ||
- echo 'restore of dmake/dbug/malloc/dump.c failed'
- Wc_c="`wc -c < 'dmake/dbug/malloc/dump.c'`"
- test 3270 -eq "$Wc_c" ||
- echo 'dmake/dbug/malloc/dump.c: original size 3270, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= dmake/dbug/malloc/free.c ==============
- if test -f 'dmake/dbug/malloc/free.c' -a X"$1" != X"-c"; then
- echo 'x - skipping dmake/dbug/malloc/free.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/free.c' &&
- /*
- X * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
- X * You may copy, distribute, and use this software as long as this
- X * copyright statement is not removed.
- X */
- #include <stdio.h>
- #include "malloc.h"
- #include "debug.h"
- X
- /*
- X * Function: free()
- X *
- X * Purpose: to deallocate malloced data
- X *
- X * Arguments: ptr - pointer to data area to deallocate
- X *
- X * Returns: nothing of any value
- X *
- X * Narrative:
- X * verify pointer is within malloc region
- X * get mlist pointer from passed address
- X * verify magic number
- X * verify inuse flag
- X * verify pointer connections with surrounding segments
- X * turn off inuse flag
- X * verify no data overrun into non-malloced area at end of segment
- X * IF possible join segment with next segment
- X * IF possible join segment with previous segment
- X * Clear all data in segment (to make sure it isn't reused)
- X *
- X */
- #ifndef lint
- static
- char rcs_hdr[] = "$Id: free.c,v 1.1 1992/01/24 03:29:02 dvadura Exp $";
- #endif
- X
- void
- free(cptr)
- X char * cptr;
- {
- X char * func = "free";
- X int i;
- X extern int malloc_checking;
- X extern struct mlist * malloc_end;
- X extern int malloc_errno;
- X extern char * malloc_data_end;
- X extern char * malloc_data_start;
- X void malloc_join();
- X void malloc_memset();
- X struct mlist * oldptr;
- X struct mlist * ptr;
- X
- X /*
- X * IF malloc chain checking is on, go do it.
- X */
- X if( malloc_checking )
- X {
- X (void) malloc_chain_check(1);
- X }
- X
- X /*
- X * verify that cptr is within the malloc region...
- X */
- X if( cptr < malloc_data_start || cptr > malloc_data_end )
- X {
- X malloc_errno = M_CODE_BAD_PTR;
- X malloc_warning(func);
- X return;
- X }
- X
- X /*
- X * convert pointer to mlist struct pointer. To do this we must
- X * move the pointer backwards the correct number of bytes...
- X */
- X
- X ptr = (struct mlist *) (cptr - M_SIZE);
- X
- X if( (ptr->flag&M_MAGIC) != M_MAGIC )
- X {
- X malloc_errno = M_CODE_BAD_MAGIC;
- X malloc_warning(func);
- X return;
- X }
- X
- X if( ! (ptr->flag & M_INUSE) )
- X {
- X malloc_errno = M_CODE_NOT_INUSE;
- X malloc_warning(func);
- X return;
- X }
- X
- X if( (ptr->prev && (ptr->prev->next != ptr) ) ||
- X (ptr->next && (ptr->next->prev != ptr) ) ||
- X ((ptr->next == NULL) && (ptr->prev == NULL)) )
- X {
- X malloc_errno = M_CODE_BAD_CONNECT;
- X malloc_warning(func);
- X return;
- X }
- X
- X ptr->flag &= ~M_INUSE;
- X
- X /*
- X * verify that the user did not overrun the requested number of bytes.
- X */
- X for(i=ptr->r_size; i < ptr->s.size; i++)
- X {
- X if( ptr->data[i] != M_FILL )
- X {
- X malloc_errno = M_CODE_OVERRUN;
- X malloc_warning(func);
- X break;
- X }
- X }
- X
- X DEBUG3(10,"pointers: prev: 0x%.7x, ptr: 0x%.7x, next: 0x%.7x",
- X ptr->prev, ptr, ptr->next);
- X
- X DEBUG3(10,"size: prev: %9d, ptr: %9d, next: %9d",
- X ptr->prev->s.size, ptr->s.size, ptr->next->s.size);
- X
- X DEBUG3(10,"flags: prev: 0x%.7x, ptr: 0x%.7x, next: 0x%.7x",
- X ptr->prev->flag, ptr->flag, ptr->next->flag);
- X
- X /*
- X * check to see if this block can be combined with the next and/or
- X * previous block. Since it may be joined with the previous block
- X * we will save a pointer to the previous block and test to verify
- X * if it is joined (it's next ptr will no longer point to ptr).
- X */
- X malloc_join(ptr,ptr->next,0,0);
- X
- X oldptr = ptr->prev;
- X
- X malloc_join(ptr->prev, ptr,0,0);
- X
- X if( oldptr->next != ptr )
- X {
- X DEBUG0(10,"Oldptr was changed");
- X ptr = oldptr;
- X }
- X
- X /*
- X * fill this block with '\02's to ensure that nobody is using a
- X * pointer to already freed data...
- X */
- X malloc_memset(ptr->data,M_FREE_FILL,(int)ptr->s.size);
- X
- }
- X
- /*
- X * $Log: free.c,v $
- X * Revision 1.1 1992/01/24 03:29:02 dvadura
- X * dmake Version 3.8, Initial revision
- X *
- X * Revision 1.9 90/08/29 21:22:48 cpcahil
- X * miscellaneous lint fixes
- X *
- X * Revision 1.8 90/05/11 00:13:08 cpcahil
- X * added copyright statment
- X *
- X * Revision 1.7 90/02/25 11:00:18 cpcahil
- X * added support for malloc chain checking.
- X *
- X * Revision 1.6 90/02/24 21:50:18 cpcahil
- X * lots of lint fixes
- X *
- X * Revision 1.5 90/02/24 17:29:13 cpcahil
- X * changed $Header to $Id so full path wouldnt be included as part of rcs
- X * id string
- X *
- X * Revision 1.4 90/02/24 15:15:32 cpcahil
- X * 1. changed ALREADY_FREE errno to NOT_INUSE so that the same errno could
- X * be used by both free and realloc (since it was the same error).
- X * 2. fixed coding bug
- X *
- X * Revision 1.3 90/02/24 14:23:45 cpcahil
- X * fixed malloc_warning calls
- X *
- X * Revision 1.2 90/02/24 13:59:10 cpcahil
- X * added function header.
- X * Modified calls to malloc_warning/malloc_fatal to use new code error messages
- X * Added support for malloc_errno setting of error codes.
- X *
- X * Revision 1.1 90/02/22 23:17:43 cpcahil
- X * Initial revision
- X *
- X */
- SHAR_EOF
- chmod 0640 dmake/dbug/malloc/free.c ||
- echo 'restore of dmake/dbug/malloc/free.c failed'
- Wc_c="`wc -c < 'dmake/dbug/malloc/free.c'`"
- test 4604 -eq "$Wc_c" ||
- echo 'dmake/dbug/malloc/free.c: original size 4604, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= dmake/dbug/malloc/m_init.c ==============
- if test -f 'dmake/dbug/malloc/m_init.c' -a X"$1" != X"-c"; then
- echo 'x - skipping dmake/dbug/malloc/m_init.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/m_init.c' &&
- /*
- X * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
- X * You may copy, distribute, and use this software as long as this
- X * copyright statement is not removed.
- X */
- #include <stdio.h>
- #include "malloc.h"
- X
- /*
- X * Function: malloc_init()
- X *
- X * Purpose: to initialize the pointers and variables use by the
- X * malloc() debugging library
- X *
- X * Arguments: none
- X *
- X * Returns: nothing of any value
- X *
- X * Narrative: Just initialize all the needed variables. Use mallopt
- X * to set options taken from the environment.
- X *
- X */
- #ifndef lint
- static
- char rcs_hdr[] = "$Id: m_init.c,v 1.1 1992/01/24 03:29:03 dvadura Exp $";
- #endif
- X
- void
- malloc_init()
- {
- X char * cptr;
- X char * getenv();
- X union malloptarg m;
- X extern char * malloc_data_end;
- X extern char * malloc_data_start;
- X extern struct mlist * malloc_end;
- X extern struct mlist malloc_start;
- X char * sbrk();
- X
- X /*
- X * If already initialized...
- X */
- X if( malloc_data_start != (char *) 0)
- X {
- X return;
- X }
- X
- X
- X malloc_data_start = sbrk(0);
- X malloc_data_end = malloc_data_start;
- X malloc_start.s.size = 0;
- X malloc_end = &malloc_start;
- X
- X if( (cptr=getenv("MALLOC_WARN")) != NULL )
- X {
- X m.i = atoi(cptr);
- X (void) mallopt(MALLOC_WARN,m);
- X }
- X
- X if( (cptr=getenv("MALLOC_FATAL")) != NULL)
- X {
- X m.i = atoi(cptr);
- X (void) mallopt(MALLOC_FATAL,m);
- X }
- X
- X if( (cptr=getenv("MALLOC_CKCHAIN")) != NULL)
- X {
- X m.i = atoi(cptr);
- X (void) mallopt(MALLOC_CKCHAIN,m);
- X }
- X
- X if( (cptr=getenv("MALLOC_ERRFILE")) != NULL)
- X {
- X m.str = cptr;
- X (void) mallopt(MALLOC_ERRFILE,m);
- X }
- X
- }
- X
- /*
- X * $Log: m_init.c,v $
- X * Revision 1.1 1992/01/24 03:29:03 dvadura
- X * dmake Version 3.8, Initial revision
- X *
- X * Revision 1.6 90/08/29 22:23:21 cpcahil
- X * fixed mallopt to use a union as an argument.
- X *
- X * Revision 1.5 90/08/29 21:22:50 cpcahil
- X * miscellaneous lint fixes
- X *
- X * Revision 1.4 90/05/11 15:53:35 cpcahil
- X * fixed bug in initialization code.
- X *
- X * Revision 1.3 90/05/11 00:13:08 cpcahil
- X * added copyright statment
- X *
- X * Revision 1.2 90/02/24 21:50:20 cpcahil
- X * lots of lint fixes
- X *
- X * Revision 1.1 90/02/24 17:10:53 cpcahil
- X * Initial revision
- X *
- X */
- SHAR_EOF
- chmod 0640 dmake/dbug/malloc/m_init.c ||
- echo 'restore of dmake/dbug/malloc/m_init.c failed'
- Wc_c="`wc -c < 'dmake/dbug/malloc/m_init.c'`"
- test 2113 -eq "$Wc_c" ||
- echo 'dmake/dbug/malloc/m_init.c: original size 2113, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= dmake/dbug/malloc/m_perror.c ==============
- if test -f 'dmake/dbug/malloc/m_perror.c' -a X"$1" != X"-c"; then
- echo 'x - skipping dmake/dbug/malloc/m_perror.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/m_perror.c' &&
- /*
- X * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
- X * You may copy, distribute, and use this software as long as this
- X * copyright statement is not removed.
- X */
- X
- #ifndef lint
- static
- char rcsid[] = "$Id: m_perror.c,v 1.1 1992/01/24 03:29:04 dvadura Exp $";
- #endif
- X
- /*
- X * malloc errno error strings...
- X */
- X
- char *malloc_err_strings[] =
- {
- X "No errors",
- X "Malloc chain is corrupted, pointers out of order",
- X "Malloc chain is corrupted, end before end pointer",
- X "Pointer is not within malloc area",
- X "Malloc region does not have valid magic number in header",
- X "Pointers between this segment and ajoining segments are invalid",
- X "Data has overrun beyond requested number of bytes",
- X "Data in free'd area has been modified",
- X "Data are is not in use (can't be freed or realloced)",
- X "Unable to get additional memory from the system",
- X "Pointer within malloc region, but outside of malloc data bounds",
- X (char *) 0
- };
- X
- /*
- X * Function: malloc_perror()
- X *
- X * Purpose: to print malloc_errno error message
- X *
- X * Arguments: str - string to print with error message
- X *
- X * Returns: nothing of any value
- X *
- X * Narrative:
- X */
- void
- malloc_perror(str)
- X char * str;
- {
- X extern int malloc_errno;
- X register char * s;
- X register char * t;
- X
- X if( str && *str)
- X {
- X for(s=str; *s; s++)
- X {
- X /* do nothing */;
- X }
- X
- X (void) write(2,str,(unsigned)(s-str));
- X (void) write(2,": ",(unsigned)2);
- X }
- X
- X t = malloc_err_strings[malloc_errno];
- X
- X for(s=t; *s; s++)
- X {
- X /* do nothing */;
- X }
- X
- X (void) write(2,t,(unsigned)(s-t));
- X
- X (void) write(2,"\n",(unsigned)1);
- }
- X
- /*
- X * $Log: m_perror.c,v $
- X * Revision 1.1 1992/01/24 03:29:04 dvadura
- X * dmake Version 3.8, Initial revision
- X *
- X * Revision 1.5 90/08/29 21:25:08 cpcahil
- X * added additional error message that was missing (and
- X * caused a core dump)
- X *
- X * Revision 1.4 90/05/11 00:13:08 cpcahil
- X * added copyright statment
- X *
- X * Revision 1.3 90/02/24 21:50:21 cpcahil
- X * lots of lint fixes
- X *
- X * Revision 1.2 90/02/24 17:39:55 cpcahil
- X * 1. added function header
- X * 2. added rcs id and log strings.
- X *
- X */
- SHAR_EOF
- chmod 0640 dmake/dbug/malloc/m_perror.c ||
- echo 'restore of dmake/dbug/malloc/m_perror.c failed'
- Wc_c="`wc -c < 'dmake/dbug/malloc/m_perror.c'`"
- test 2064 -eq "$Wc_c" ||
- echo 'dmake/dbug/malloc/m_perror.c: original size 2064, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= dmake/dbug/malloc/malloc.3 ==============
- if test -f 'dmake/dbug/malloc/malloc.3' -a X"$1" != X"-c"; then
- echo 'x - skipping dmake/dbug/malloc/malloc.3 (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- sed 's/^X//' << 'SHAR_EOF' > 'dmake/dbug/malloc/malloc.3' &&
- .TH MALLOC 3 "" "" "1.0"
- .ds ]T
- .\"/*
- .\" * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
- .\" * You may copy, distribute, and use this software as long as this
- .\" * copyright statement is not removed.
- .\" */
- .\" $Id: malloc.3,v 1.3 90/08/29 22:24:44 cpcahil Exp $
- .SH NAME
- malloc \t- debugging malloc library
- .SH SYNOPSIS
- .ft B
- .nf
- #include <malloc.h>
- X
- char * calloc(nelem,elsize);
- void free(ptr);
- char * malloc(size);
- int malloc_chain_check(flag);
- void malloc_dump(fd);
- int mallopt(cmd,val)
- char * realloc(ptr,size);
- X
- int cmd,fd,flag;
- unsigned elsize,nelem,size;
- char * ptr;
- union malloptarg val;
- X
- .fi
- .ft R
- .SH DESCRIPTION
- This malloc library is a replacement for the standard library to be used
- during software development/debugging. See the standard malloc(3) pages
- for more information on the use of the following functions:
- .nf
- .in +.5i
- calloc(), free(), malloc(), realloc()
- .in -.5i
- .fi
- .sp
- This library differs from the standard malloc library in the
- following ways:
- .P
- 1. Each malloc segment contains a magic number so that free can
- verify that the pointer passed points to a valid malloc segment.
- .P
- 2. Each malloc segment is filled with a non-zero pattern so that code that
- depends upon malloc segments being null will fail.
- .P
- 3. The size of each segment will be at least 1 byte larger than requested
- and the extra bytes will be filled with a non-zero pattern. When free is
- called, it will verify that you did not go beyond the number of bytes
- you asked for.
- .P
- 4. When a segment is freed, it will be filled with a different non-zero pattern
- to ensure that the program doesn't depend upon the use of already freed data.
- .P
- 5. Whenever any of the string or memory functions (str*, b*, mem*) are
- called with a pointer that is within the malloc arena, the operation is
- checked to verify that it does not overrun the malloced segment. A failure
- SHAR_EOF
- true || echo 'restore of dmake/dbug/malloc/malloc.3 failed'
- fi
- echo 'End of part 4, continue with part 5'
- echo 5 > _shar_seq_.tmp
- exit 0
- exit 0 # Just in case...
-